#pragma once

#include "logicbase/GLGroupBase.h"
#include "GLGlobalInfo.h"
#include <vector>

class CGLGroup /*: public CGLGroupBase*/ {
public:
	typedef std::vector<AnimalLookInfo>		VecLook_t;
public:
	CGLGroup(void);
	virtual ~CGLGroup(void);

	void SetId(const uint64_t& id) { m_Id = id; }
	const uint64_t& GetId() const { return m_Id; }

	bool Add(const AnimalLookInfo& info);
	bool Rem(const AnimalLookInfo& info);
	bool Rem(const uint64_t& uid);
	inline AnimalLookInfo* GetMember(GroupIndex index) const { return m_Members[index]; }

	void AddApply(const AnimalLookInfo& info) { m_Applys.push_back(info); }
	inline void RemApply(const AnimalLookInfo& info);
	inline void RemApply(int32_t index);
	VecLook_t& AllApply() { return m_Applys; }
private:
	uint64_t					m_Id;
	AnimalLookInfo*				m_Members[GroupCount];

	VecLook_t					m_Applys;
};

void CGLGroup::RemApply(const AnimalLookInfo& info) {
	m_Applys.push_back(info);
	for (VecLook_t::iterator it = m_Applys.begin(); it != m_Applys.end(); ++it) {
		const AnimalLookInfo& tInfo = *it;
		if (tInfo.m_Uid == info.m_Uid && tInfo.m_Type == info.m_Type) {
			m_Applys.erase(it);
			break;
		}
	}
}
void CGLGroup::RemApply(int32_t index) {
	if (index < (int32_t)m_Applys.size()) {
		int32_t tIndex = 0;
		for (VecLook_t::iterator it = m_Applys.begin(); it != m_Applys.end(); ++it) {
			if (index == tIndex) {
				m_Applys.erase(it);
				break;
			}
			++tIndex;
		}
	}
}

